import pygame

from model.blocks.Lava import Lava
from view.blockImgs.BlockImg import BlockImg


class LavaImg(BlockImg):
    def __init__(self, img_type, img_path="resources/地形/lava 0.png", x_position=0, y_position=0):
        BlockImg.__init__(self, img_path, x_position, y_position)
        self.step=0

    def update_step(self):
        self.step += 1
        self.step = self.step % 4

    def change_image(self, multiple=1.5, img_path=""):
        image = pygame.image.load(img_path)
        rect = image.get_rect()
        image = pygame.transform.scale(image, (int(rect.width * multiple), int(rect.height * multiple)))
        self.rect = image.get_rect()
        self.image = image

    def update(self):
        self.update_step()
        self.change_image(img_path="resources/地形/lava " + self.step.__str__() + ".png")
        self.rect.centerx = int(self.location[0] * 48 + 48 - self.rect.width // 2)
        self.rect.bottom = int(self.location[1] * 48 + 96 - self.rect.height)
